package com.ruoyi.my.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.my.domain.CfUserImage;
import com.ruoyi.my.service.ICfUserImageService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 用户历史照片Controller
 * 
 * @author shenshen
 * @date 2024-06-05
 */
@RestController
@RequestMapping("/userimage")
public class CfUserImageController extends BaseController
{
    @Autowired
    private ICfUserImageService cfUserImageService;

    /**
     * 查询用户历史照片列表
     */
    @RequiresPermissions("my:userimage:list")
    @GetMapping("/list")
    public TableDataInfo list(CfUserImage cfUserImage)
    {
        startPage();
        List<CfUserImage> list = cfUserImageService.selectCfUserImageList(cfUserImage);
        return getDataTable(list);
    }

    /**
     * 导出用户历史照片列表
     */
    @RequiresPermissions("my:userimage:export")
    @Log(title = "用户历史照片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CfUserImage cfUserImage)
    {
        List<CfUserImage> list = cfUserImageService.selectCfUserImageList(cfUserImage);
        ExcelUtil<CfUserImage> util = new ExcelUtil<CfUserImage>(CfUserImage.class);
        util.exportExcel(response, list, "用户历史照片数据");
    }

    /**
     * 获取用户历史照片详细信息
     */
    @RequiresPermissions("my:userimage:query")
    @GetMapping(value = "/{userImageId}")
    public AjaxResult getInfo(@PathVariable("userImageId") Long userImageId)
    {
        return success(cfUserImageService.selectCfUserImageByUserImageId(userImageId));
    }

    /**
     * 新增用户历史照片
     */
    @RequiresPermissions("my:userimage:add")
    @Log(title = "用户历史照片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CfUserImage cfUserImage)
    {
        return toAjax(cfUserImageService.insertCfUserImage(cfUserImage));
    }

    /**
     * 修改用户历史照片
     */
    @RequiresPermissions("my:userimage:edit")
    @Log(title = "用户历史照片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CfUserImage cfUserImage)
    {
        return toAjax(cfUserImageService.updateCfUserImage(cfUserImage));
    }

    /**
     * 删除用户历史照片
     */
    @RequiresPermissions("my:userimage:remove")
    @Log(title = "用户历史照片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userImageIds}")
    public AjaxResult remove(@PathVariable Long[] userImageIds)
    {
        return toAjax(cfUserImageService.deleteCfUserImageByUserImageIds(userImageIds));
    }
}
